package com.yyi.springcloud.controller;

import com.github.pagehelper.PageInfo;
import com.yyi.springcloud.entities.TestProdInfoValueModel;
import com.yyi.springcloud.service.Local_TestProdInfoValueService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
@RequestMapping("/mysqlapi/TestProdInfoValue")
public class Mysql_TestProdInfoValueController {
	@Resource
	private Local_TestProdInfoValueService testProdInfoValueService;

	// http://localhost:8080/bxxs/mysqlapi/TestProdInfoValue/getAllTestProdInfoValue
	@ResponseBody
	@RequestMapping(value = "/getAllTestProdInfoValue", method = RequestMethod.GET)
	public PageInfo<TestProdInfoValueModel> getSensorInfo(HttpServletRequest request, HttpServletResponse response) {
		String labcode = request.getParameter("labcode");
		int pageNum = Integer.parseInt(request.getParameter("pageNum") == null ? "1" : request.getParameter("pageNum"));
		int pageSize = Integer
				.parseInt(request.getParameter("pageSize") == null ? "10" : request.getParameter("pageSize"));
		TestProdInfoValueModel testProdInfoValueModel = new TestProdInfoValueModel();
		PageInfo<TestProdInfoValueModel> allTestProdInfoValuePage = testProdInfoValueService
				.getAllTestProdInfoValueByCondition(testProdInfoValueModel, pageNum, pageSize, null);
		return allTestProdInfoValuePage;
	}

	/**
	 * 2.查询所有开测台位的信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	// http://localhost:8080/bxxs/api/TestProdInfoValue/getAllTestProdInfoValueNow?labcode=Haierrefrigerator20151214
	@ResponseBody
	@RequestMapping(value = "/getAllTestProdInfoValueNow", method = RequestMethod.GET)
	public List<TestProdInfoValueModel> getAllTestProdInfoValueNow(HttpServletRequest request,
			HttpServletResponse response) {
		String labcode = request.getParameter("labcode");
		TestProdInfoValueModel testProdInfoValueModel = new TestProdInfoValueModel();
		testProdInfoValueModel.setLabcode(labcode);
		// 查询所有开测的台位
		testProdInfoValueModel.setTestnow(1);
		List<TestProdInfoValueModel> allTestProdInfoValueNow = testProdInfoValueService
				.getAllTestProdInfoValueNow(testProdInfoValueModel);
		return allTestProdInfoValueNow;
	}
}
